<%= render 'public/flash_notice' %>
<%= render partial: 'public/errors', locals: { obj: @product } %>

<%= form_for [:cpanel, @product], html: { multipart: true, role: 'form'} do |f| %>
  <div class="form-group">
    <%= f.label :产品语言 %>
    <%= f.select(:language, [['简体中文', 1], ['英文', 2], ['繁体中文', 3]], select: @product.language || 1) %>
  </div>
  <div class="form-group">
    <%= f.label :产品名称 %>
    <%= f.text_field :title, value: @product.title, class: 'form-control' %>
  </div>
  <div class="form-group">
    <%= f.label :产品描述 %>
    <%= f.text_area :description, value: @product.description, class: 'form-control', id: 'editor' %>
  </div>
  <div class="form-group">
    <%= f.label :上传logo图 %>
    <%= f.file_field :logo_img %>
  </div>

  <div class="form-group">
    <%= f.label :上传展示图 %>
    <%= file_field_tag "photo[]", multiple: "multiple" %>
  </div>

  <%= edit_controller_for params[:action] do %>

    <div class="good-photos">
      <ul>
        <% @product.photos.each do |photo| %>
          <li id="photo_<%= photo.id %>">
              <%= image_tag photo.path.url %>
              <%= link_to 'X', [:cpanel, @product, photo], method: :delete, remote: true, data: {confirm: ' 确认删除？'} %>
          </li>
        <% end %>
      </ul>
    </div>

  <% end %>

  <div class="form-group">
    <%= f.submit '提交', class: 'btn btn-primary'%>
    <%= link_to '返回', cpanel_products_path, class: 'btn btn-default' %>
  </div>

<% end %>
